package com.ruoyi.front.ap.controller;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.framework.web.service.SysLoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author：HuaQP
 * @Date：2023/10/7
 */
@Anonymous
@Api(value = "LoginController",tags = {"农产品大屏_登录"})
@RestController
@RequestMapping(value = "/lsd")
public class LoginController {

    @Resource
    private SysLoginService loginService;


    /**
     * 登录方法
     */
    @ApiOperation("01_用户登录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name",value = "用户名",dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "password",value = "密码",dataType = "String",paramType = "query")
    })
    @GetMapping("/login")
    public AjaxResult login(String name,String password)
    {
        AjaxResult ajax = AjaxResult.success();
        // 生成令牌
        String token = loginService.login(name,password, null,null);
        ajax.put(Constants.TOKEN, token);
        return ajax;
    }
}
